﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using XbsWebAPI.Application;
using XbsWebAPI.Application.Feedback;
using XbsWebAPI.Application.Feedback.Dto;

namespace XbsWebAPI.MainHost.Controllers
{

    [ApiController]
    [Route("api/xbs_v1/[controller]")]
    public class FeedbackController : ControllerBase
    {
        private readonly IFeedBackAppService _feedBackAppService;
        public FeedbackController(IFeedBackAppService feedBackAppService)
        {
            _feedBackAppService = feedBackAppService;
        }
        /// <summary>
        /// 新增意见反馈
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost, Route("[action]")]
        public Task<ResultDto<string>> AddFeedBack(FeedBackDto model)
        {

            return _feedBackAppService.AddFeedBack(model);
        }

        /// <summary>
        /// 分页查询意见反馈
        /// </summary>
        /// <param name="data">模糊查询条件</param>
        /// <param name="pageNumber">第几页，默认1</param>
        /// <param name="pageSize">每页多少条，默认10</param>
        /// <returns></returns>
        [HttpGet, Route("[action]")]
        public ResultDto<PageListDto<ListFeedBackDto>> FindFeedBackPagedList(string data, int? pageNumber, int? pageSize)
        {
            return _feedBackAppService.GetFeedBackPagedList(new Application.QueryModel.QueryFeedBack() { Data = data, PageNumber = pageNumber, PageSize = pageSize });
        }

        ///<summary>
        ///删除意见反馈
        ///</summary>
        [HttpGet, Route("[action]")]
        public async Task<ResultDto<string>> DeleteFeedBack(Guid id)
        {
            return await _feedBackAppService.DeleteFeedBack(id);
        }
    }
}
